//-----------------------------------------------------------------------
// <copyright file="UnitTypeService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class UnitTypeService
    {
        #region UnitType

        public static void CreateUnitType(UnitType unitType)
        {            
            try
            {
                UnitTypeDAO unitTypeDAO = new UnitTypeDAO();
                unitTypeDAO.CreateUnitType(unitType);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateUnitTypeException, ex);
            }
        }        

        public static void UpdateUnitType(UnitType unitType)
        {            
            try
            {
                UnitTypeDAO unitTypeDAO = new UnitTypeDAO();
                unitTypeDAO.UpdateUnitType(unitType);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateUnitTypeException, ex);
            }
        }        

        public static void DeleteUnitType(long unitTypeId)
        {            
            try
            {
                UnitTypeDAO unitTypeDAO = new UnitTypeDAO();
                unitTypeDAO.DeleteUnitType(unitTypeId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteUnitTypeException, ex);
            }
        }
        
        public static UnitType GetUnitType(long unitTypeId)
        {            
            try
            {
                UnitTypeDAO unitTypeDAO = new UnitTypeDAO();
                return unitTypeDAO.GetUnitType(unitTypeId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUnitTypeException, ex);
            }
        }                

        public static UnitTypeCollection GetUnitTypeList(UnitTypeColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                UnitTypeDAO unitTypeDAO = new UnitTypeDAO();
                return unitTypeDAO.GetUnitTypeList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUnitTypeListException, ex);
            }
        }        

        public static UnitTypeCollection GetUnitTypeList(UnitTypeColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                UnitTypeDAO unitTypeDAO = new UnitTypeDAO();
                return unitTypeDAO.GetUnitTypeList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUnitTypeListException, ex);
            }
        }        

	    public static UnitTypeCollection GetUnitTypeListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                UnitTypeDAO unitTypeDAO = new UnitTypeDAO();
                return unitTypeDAO.GetUnitTypeListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUnitTypeListException, ex);
            }
        }        

        public static UnitTypeCollection GetUnitTypeListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                UnitTypeDAO unitTypeDAO = new UnitTypeDAO();
                return unitTypeDAO.GetUnitTypeListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUnitTypeListException, ex);
            }
        }        

        #endregion
    }
}